package com.example.hello.views.organizations;

import com.example.hello.BootstrapButton;
import com.example.hello.views.users.Users;
import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;

public class EditOrg extends VerticalLayout implements View {

    public static final String NAME = "edit_org";

    private String org;

    @Override
    public void enter(ViewChangeListener.ViewChangeEvent event) {

    }

    public EditOrg() {
        BootstrapButton addUser = new BootstrapButton("Add User");

        final TextField name = new TextField("Name");

        addUser.addListener(new Listener() {
            @Override
            public void componentEvent(Event event) {
                org = name.getValue();
                getUI().getSession().setAttribute("previousView", "edit_org");
                getUI().getNavigator().navigateTo(Users.NAME);
            }
        });

        addComponent(name);
        addComponent(addUser);
    }

    public String getOrg() {
        return org;
    }

}